﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using System.Data;
using System.Collections;
using KPIS.GERP.ESS.BLL;
using KPIS.GERP.ESS.MODEL;

namespace KPIS.GERP.ESS.APP.App_UI.UserControls
{
    public partial class ChangePersonal : System.Web.UI.UserControl
    {
        private B_HrmRequest reqBLL = new B_HrmRequest();
        private B_HrmChangeData perBLL = new B_HrmChangeData();
        private B_HrmEmployees empBLL = new B_HrmEmployees();
        private B_HrmMasters masBLL = new B_HrmMasters();
        private B_MessageSend mesBLL = new B_MessageSend();
        private B_MessageReply replyBLL = new B_MessageReply();

        private const int ItemsPerRequest = 10;

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected bool IsUserControlPostBack
        {
            get
            {                
                return this.ViewState["IsUserControlPostBack"] != null;
            }
        }
        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);

            if (!IsUserControlPostBack)
            {                
                this.ViewState.Add("IsUserControlPostBack", true);
            }
        }
       
        public void LoadDataEditInsert(int Sequence)
        {
            DataSet ds = null;
            DataTable dt = null;

            if (Sequence > 0)
            {
                OnUpdateCmdUI("EDIT");
                ds = perBLL.GetChangeData(Sequence, (int?)null, (int?)null, ""); //empBLL.GetEmployeeInfo(Int32.Parse(Session["EmpSeq"].ToString()), "");

                if (ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0];
                    lblRefNo.Text = dt.Rows[0]["REF_NO"].ToString();
                    lblCreatedDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["CREATED_WHEN"]);
                    cmbNamePrefix.Items.Add(new RadComboBoxItem(dt.Rows[0]["PREFIX_NAME"].ToString(), dt.Rows[0]["NAME_PREFIX_SEQ"].ToString()));
                    cmbNamePrefix.SelectedValue = dt.Rows[0]["NAME_PREFIX_SEQ"].ToString();
                    cmbRaceNational.Items.Add(new RadComboBoxItem(dt.Rows[0]["RACE_NAT_NAME"].ToString(), dt.Rows[0]["RACE_NAT_SEQ"].ToString()));
                    cmbRaceNational.SelectedValue = dt.Rows[0]["RACE_NAT_SEQ"].ToString();
                    cmbNational.Items.Add(new RadComboBoxItem(dt.Rows[0]["NAT_NAME"].ToString(), dt.Rows[0]["NAT_SEQ"].ToString()));
                    cmbNational.SelectedValue = dt.Rows[0]["NAT_SEQ"].ToString();
                    cmbReligion.Items.Add(new RadComboBoxItem(dt.Rows[0]["RELIGION_NAME"].ToString(), dt.Rows[0]["RELIGION_SEQ"].ToString()));
                    cmbReligion.SelectedValue = dt.Rows[0]["RELIGION_SEQ"].ToString();
                    cmbBloodGroup.Items.Add(new RadComboBoxItem(dt.Rows[0]["BLOOD_GROUP_NAME"].ToString(), dt.Rows[0]["BLOOD_GROUP_SEQ"].ToString()));
                    cmbBloodGroup.SelectedValue = dt.Rows[0]["BLOOD_GROUP_SEQ"].ToString();                  
                    
                    txtRemarks.Text = dt.Rows[0]["REMARKS"].ToString();
                }
            }
            else
            {
                OnUpdateCmdUI("ADDNEW");
                ds = empBLL.GetEmployeeInfo(Int32.Parse(Session["EmpSeq"].ToString()), "");

                if (ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0];
                    lblRefNo.Text = "ต้องบันทึกข้อมูลก่อน";
                    lblCreatedDate.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Today);
                    //lblName.Text = dt.Rows[0]["FULL_NAME"].ToString();
                    //lblPosName.Text = dt.Rows[0]["POS_NAME"].ToString();
                    //lblJobSiteName.Text = dt.Rows[0]["JOB_SITE_NAME"].ToString();
                    //lblApprovedDate.Text = "รอการพิจารณา";
                    //lblStatusName.Text = "รอการพิจารณา";
                }
            }
        }
        public void LoadDataView(int Sequence)
        {
            OnUpdateCmdUI("VIEW");
            LoadData(Sequence);
        }
        public void LoadData(int Sequence)
        {
            DataSet ds = reqBLL.GetRequestAbsences(Sequence, (int?)null, ""); //empBLL.GetEmployeeInfo(Int32.Parse(Session["EmpSeq"].ToString()), "");
            DataTable dt = null;

            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    lblAbsenceSeq.Text = dt.Rows[0]["ABSENCE_SEQ"].ToString();
                    lblSendSeq.Text = dt.Rows[0]["SEND_SEQ"].ToString();
                    lblEmpSeq.Text = dt.Rows[0]["EMP_SEQ"].ToString();
                    lblRefNo.Text = dt.Rows[0]["REF_NO"].ToString();
                    lblCreatedDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["CREATED_WHEN"]);
                    //lblName.Text = dt.Rows[0]["FULL_NAME"].ToString();
                    //lblPosName.Text = dt.Rows[0]["POS_NAME"].ToString();
                    //lblJobSiteName.Text = dt.Rows[0]["JOB_SITE_NAME"].ToString();
                    //lblAbsenceTypeName.Text = dt.Rows[0]["ABSENCE_TYPE_NAME"].ToString();
                    //lblStartDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["START_DATE"]);
                    //rdoStartTime.SelectedValue = dt.Rows[0]["START_TIME"].ToString();
                    //lblEndDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["END_DATE"]);
                    //rdoEndTime.SelectedValue = dt.Rows[0]["END_TIME"].ToString();
                    //lblCountDate.Text = string.Format("{0:###.##}", dt.Rows[0]["COUNT_DATE"]);
                    //lblAddress.Text = dt.Rows[0]["CONTACT_ADDRESS"].ToString();
                    //lblApprovedBy.Text = dt.Rows[0]["APPROVED_BY"].ToString();
                    //lblApprovedName.Text = dt.Rows[0]["APPROVED_NAME"].ToString();
                    //lblApprovedDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["APPROVED_DATE"]);
                    //lblRemarks.Text = dt.Rows[0]["ABSENCE_REASON"].ToString();
                    //lblStatusName.Text = dt.Rows[0]["APPROVED_STATUS_NAME"].ToString();
                    //lblStatus.Text = dt.Rows[0]["APPROVED_STATUS"].ToString();
                    //lblApprovedReason.Text = dt.Rows[0]["APPROVED_REASON"].ToString();
                    //rdoApproveStatus.SelectedValue = dt.Rows[0]["APPROVED_STATUS"].ToString();
                    //txtApproveDate.SetValue(dt.Rows[0]["APPROVED_DATE"]);
                    //txtApprovedReason.Text = dt.Rows[0]["APPROVED_REASON"].ToString();
                    
                }
            }
        }
        public void LoadDataApproved(int Sequence)
        {
            OnUpdateCmdUI("APPROVED");            
            LoadData(Sequence);
            // กรณีพิจารณาไปแล้ว ************************************
            bool bApproved = lblStatus.Text == "W";
            bool bAgree = lblStatus.Text == "1";

            btnUpdate.Visible = bApproved;
            //lblStatusName.Visible = !bApproved;
            //rdoApproveStatus.Visible = bApproved;
            //txtApproveDate.Visible = bApproved;
            //lblApprovedDate.Visible = !bApproved;
            //lblApprovedReason.Visible = !bApproved;
            //**************************************************
            UpdateSendMessageStatus(lblSendSeq.Text, SystemInfo._ReadMessage);
        }
        private void OnUpdateCmdUI(string Mode)
        {
            bool bViewMode = Mode == "VIEW";
            bool bAddNewMode = Mode == "ADDNEW";
            bool bEditMode = Mode == "EDIT";
            bool bApprovedMode = Mode == "APPROVED";
            bool bNull = Mode == "";

            btnAddnew.Visible = bAddNewMode;
            btnUpdate.Visible = bEditMode || bApprovedMode;
            btnCancel.Visible = !bViewMode && !bApprovedMode;
            btnBackHome.Visible = bViewMode;
            btnEditMode.Visible = bViewMode;
            btnViewRequest.Visible = bApprovedMode;

            //cmbAbsenceType.Visible = !bViewMode && !bApprovedMode;
            //txtStartDate.Visible = !bViewMode && !bApprovedMode;
            //rdoStartTime.Enabled = !bViewMode && !bApprovedMode;
            //txtEndDate.Visible = !bViewMode && !bApprovedMode;
            //rdoEndTime.Enabled = !bViewMode && !bApprovedMode;
            //txtCountDate.Visible = !bViewMode && !bApprovedMode;
            //txtContactAddress.Visible = !bViewMode && !bApprovedMode;
            //cmbAppSeq.Visible = !bViewMode && !bApprovedMode;
            //txtReason.Visible = !bViewMode && !bApprovedMode;
            //txtApproveDate.Visible = bApprovedMode;
            //rdoApproveStatus.Visible = bApprovedMode;

            //lblAbsenceTypeName.Visible = bViewMode || bApprovedMode;
            //lblStartDate.Visible = bViewMode || bApprovedMode;
            //lblEndDate.Visible = bViewMode || bApprovedMode;
            //lblCountDate.Visible = bViewMode || bApprovedMode;
            //lblAddress.Visible = bViewMode || bApprovedMode;
            //lblApprovedName.Visible = bViewMode || bApprovedMode;
            //lblApprovedDate.Visible = !bApprovedMode;
            //lblRemarks.Visible = bViewMode || bApprovedMode;
            //lblStatusName.Visible = !bApprovedMode;
            //lblApprovedReason.Visible = bViewMode;
        }
        private static string GetStatusMessage(int offset, int total)
        {
            if (total <= 0)
                return "ไม่มีข้อมูล";

            return String.Format("รายการที่ <b>1</b>-<b>{0}</b> จากทั้งหมด <b>{1}</b> รายการ", offset, total);
        }
        protected void ListApproverCombo()
        {
            //DataSet ds = posBLL.GetPositionUpper(Int32.Parse(Session["EmpSeq"].ToString()), (int?)null, "");
            //DataTable dt = null;
            //if (ds.Tables.Count > 0)
            //{
            //    dt = ds.Tables[0];
            //    cmbAppSeq.DataSource = dt;
            //    cmbAppSeq.DataBind();
            //}
        }
        protected void UpdateSendMessageStatus(string strSendSeq, string strMessageStatus)
        {
            string strEmpID = Session["EmpSeq"].ToString();
            M_MessageSend info = new M_MessageSend();

            info.send_seq = Convert.ToInt32(strSendSeq);
            info.message_status = strMessageStatus;
            info.updated_by = Int32.Parse(strEmpID);
            info.updated_when = DateTime.Now;

            mesBLL.UpdateMessageStatus(info);
        }       

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            //if (btnViewRequest.Visible)//กรณี ผู้อนุมัติเข้ามาดู
            //{
            //    Forword();
            //    UpdateSendMessageStatus(lblSendSeq.Text, SystemInfo._ReplyMessage);
            //    reqBLL.UpdateAbsenceStatus(Int32.Parse(lblAbsenceSeq.Text)
            //        , rdoApproveStatus.SelectedValue
            //        , DateTime.Parse(txtApproveDate.GetStringValue())
            //        , Int32.Parse(Session["EmpSeq"].ToString())
            //        );
            //    ((Forms.TaskLists)this.Parent.Page).ViewRequest();
            //}
            //else
            //{   // กรณีเจ้าตัวเข้ามาแก้ไข
            //    reqBLL.UpdateAbsence(Int32.Parse(lblAbsenceSeq.Text)
            //        , cmbAbsenceType.SelectedValue
            //        , Session["EmpSeq"].ToString()
            //        , DateTime.Parse(txtStartDate.GetStringValue())
            //        , rdoStartTime.SelectedValue
            //        , DateTime.Parse(txtEndDate.GetStringValue())
            //        , rdoEndTime.SelectedValue
            //        , string.IsNullOrEmpty(txtCountDate.Text) ? 0 : decimal.Parse(txtCountDate.Text)
            //        , txtContactAddress.Text.Trim()
            //        , SystemInfo._WorkRecordStatus
            //        , cmbAppSeq.SelectedValue
            //        , ""
            //        , (DateTime?)null
            //        , txtReason.Text.Trim()
            //        , Int32.Parse(Session["EmpSeq"].ToString()));
            //    LoadDataView(Int32.Parse(lblAbsenceSeq.Text));
            //}
        }
        private void InsertSend(Nullable<int> ForwordSendSeq)
        {
            M_MessageSend sendInfo = new M_MessageSend();

            sendInfo.send_date = DateTime.Today;
            sendInfo.ref_no = mesBLL.GetNextSendRefNo("AB");
            sendInfo.send_text = "ใบลา";
            sendInfo.ref_type = "hrm_ps_absences";
            sendInfo.ref_seq = Int32.Parse(lblAbsenceSeq.Text);
            sendInfo.from_emp_seq = Convert.ToInt32(Session["EmpSeq"].ToString());            
            sendInfo.remarks = null;
            sendInfo.message_status = "0";

            //if (ForwordSendSeq.HasValue)
            //{
            //    sendInfo.send_seq = (int)ForwordSendSeq;
            //    sendInfo.to_emp_seq = Convert.ToInt32(cmbNextApprover.SelectedValue);
            //    sendInfo.updated_by = Convert.ToInt32(Session["EmpSeq"].ToString());
            //    sendInfo.updated_when = DateTime.Now;

            //    mesBLL.Update(sendInfo);                
            //}
            //else 
            //{
            //    sendInfo.to_emp_seq = Convert.ToInt32(cmbAppSeq.SelectedValue);
            //    sendInfo.created_by = Convert.ToInt32(Session["EmpSeq"].ToString());
            //    sendInfo.created_when = DateTime.Now;

            //    mesBLL.Insert(sendInfo);
            //}           
        }
        protected string CheckIsForword()
        {
            string strForwordSendSeq = null;
            string strSendSeq = lblSendSeq.Text;

            ESS.MODEL.M_MessageSend info = mesBLL.GetInfoFromFromSendSeq(strSendSeq);
            if (info != null)
            {
                strForwordSendSeq = info.send_seq.ToString();
            }

            return strForwordSendSeq;
        }
        private void Reply()
        {
            //================ insert message_reply ====================
            ESS.MODEL.M_MessageReply ReplyInfo = new ESS.MODEL.M_MessageReply();

            string strUserID = Session["EmpSeq"].ToString();

            ReplyInfo.reply_date = DateTime.Today;
            ReplyInfo.ref_no = null;
            ReplyInfo.reply_text = "เห็นสมควรให้ลา";
            ReplyInfo.from_emp_seq = Int32.Parse(strUserID);
            ReplyInfo.to_emp_seq = Int32.Parse(lblEmpSeq.Text);
            ReplyInfo.from_send_seq =Int32.Parse(lblSendSeq.Text);
            //ReplyInfo.remarks = txtApprovedReason.Text;
            //ReplyInfo.reply_type = rdoApproveStatus.SelectedValue;
            ReplyInfo.message_status = "0";
            ReplyInfo.created_by = Int32.Parse(strUserID);
            ReplyInfo.created_when = DateTime.Now;

            replyBLL.Insert(ReplyInfo);
        }
        private void Forword()
        {
            //string strUserID = Session["EmpSeq"].ToString();
            //string strSendSeq = lblSendSeq.Text;
            //string strForwordSendSeq = null;
            //string strReplyText = null;

            //switch (rdoApproveStatus.SelectedValue)
            //{
            //    case "0"://ไม่เห็นด้วย
            //        //strReplyText = txtApprovedReason.Text;
            //        strForwordSendSeq = CheckIsForword();

            //        if (!string.IsNullOrEmpty(strForwordSendSeq))
            //        {
            //            ESS.MODEL.M_MessageSend info = new ESS.MODEL.M_MessageSend();
            //            info.send_seq = Convert.ToInt32(strForwordSendSeq);
            //            info.message_status = "0";
            //            info.updated_by = string.IsNullOrEmpty(strUserID) ? (int?)null : Int32.Parse(strUserID);
            //            info.updated_when = DateTime.Now;
            //            mesBLL.UpdateMessageStatus(info);
            //        }
            //        break;
            //    case "1":
            //        strReplyText = "เห็นสมควรให้ลา";
            //        strForwordSendSeq = CheckIsForword();

            //        ESS.MODEL.M_MessageSend sendInfo = new ESS.MODEL.M_MessageSend();
            //        sendInfo.send_seq = Convert.ToInt32(strForwordSendSeq);
            //        sendInfo.message_status = "1";
            //        sendInfo.updated_by = string.IsNullOrEmpty(strUserID) ? (int?)null : Int32.Parse(strUserID);
            //        sendInfo.updated_when = DateTime.Now;
            //        mesBLL.UpdateMessageStatus(sendInfo);
            //        Reply();
            //        break;
            //    case "2":
            //        strReplyText = "เห็นสมควรให้ลา และรอการพิจารณาในขั้นต่อไป";
            //        strForwordSendSeq = CheckIsForword();
            //        InsertSend(Int32.Parse(strForwordSendSeq));
            //        break;
            //}
        }        
        
        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            perBLL.Insert(1
                , string.IsNullOrEmpty(cmbNamePrefix.SelectedValue) ? (int?)null : Int32.Parse(cmbNamePrefix.SelectedValue)
                , txtFirstName.Text
                , txtLastName.Text
                , txtFirstNameEng.Text
                , txtLastNameEng.Text
                , ""
                , txtCitizen.Text
                , ""
                , ""
                , ""
                , (int?)null
                , cmbReligion.SelectedValue
                , cmbRaceNational.SelectedValue
                , cmbNational.SelectedValue
                , cmbBloodGroup.SelectedValue
                , string.IsNullOrEmpty(txtBirthDate.GetStringValue()) ? (DateTime?)null : DateTime.Parse(txtBirthDate.GetStringValue())
                , txtRemarks.Text
                , Int32.Parse(Session["EmpSeq"].ToString()));          

            //lblAbsenceSeq.Text = reqBLL.GetAbsenceSequence().ToString();
            //InsertSend((int?)null);
            //LoadDataView(Int32.Parse(lblAbsenceSeq.Text));
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            LoadDataView(Int32.Parse(lblAbsenceSeq.Text));
        }
                
        protected void btnEditMode_Click(object sender, EventArgs e)
        {
            LoadDataEditInsert(Int32.Parse(lblAbsenceSeq.Text));
        }
        protected void btnBackHome_Click(object sender, EventArgs e)
        {
            ((Forms.RequestAbsences)this.Parent.Page).ViewGrid();            
        }

        protected void rdoApproveStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            //bool bNotApproved = rdoApproveStatus.SelectedValue == "0";
            //bool bNext = rdoApproveStatus.SelectedValue == "2";

            //// กรณีไม่เห็นด้วย
            //lblApprovedReasonTitle.Visible = bNotApproved;
            //txtApprovedReason.Visible = bNotApproved;

            //// กรณีส่งให้พิจารณาต่อ
            //lblNextApprovedTitle.Visible = bNext;
            //cmbNextApprover.Visible = bNext;
        }

       protected void btnViewRequest_Click(object sender, EventArgs e)
        {
            ((Forms.TaskLists)this.Parent.Page).ViewRequest();
        }

        protected void cmbNamePrefix_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbNamePrefix.Items.Clear();

            DataSet ds = null;
            ds = masBLL.LoadNamePrefixes((int?)null, (int?)null, e.Text);
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];

                int itemOffset = e.NumberOfItems;
                int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
                e.EndOfItems = (endOffset == dt.Rows.Count);
                //int j = 0;
                for (int i = itemOffset; i < endOffset; i++)
                {
                    cmbNamePrefix.Items.Add(new RadComboBoxItem(dt.Rows[i]["PREFIX_NAME"].ToString(), dt.Rows[i]["NAME_PREFIX_SEQ"].ToString()));
                    //j++;
                }
            }
        }

        protected void cmbRaceNational_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbRaceNational.Items.Clear();

            DataSet ds = null;
            ds = masBLL.LoadNationalities((int?)null, e.Text);
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];

                int itemOffset = e.NumberOfItems;
                int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
                e.EndOfItems = (endOffset == dt.Rows.Count);
                //int j = 0;
                for (int i = itemOffset; i < endOffset; i++)
                {
                    cmbRaceNational.Items.Add(new RadComboBoxItem(dt.Rows[i]["NAT_NAME"].ToString(), dt.Rows[i]["NAT_SEQ"].ToString()));
                    //j++;
                }
            }
        }

        protected void cmbNational_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbNational.Items.Clear();

            DataSet ds = null;
            ds = masBLL.LoadNationalities((int?)null, e.Text);
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];

                int itemOffset = e.NumberOfItems;
                int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
                e.EndOfItems = (endOffset == dt.Rows.Count);
                //int j = 0;
                for (int i = itemOffset; i < endOffset; i++)
                {         
                    cmbNational.Items.Add(new RadComboBoxItem(dt.Rows[i]["NAT_NAME"].ToString(), dt.Rows[i]["NAT_SEQ"].ToString()));
                    //j++;
                }
            }
        }

        protected void cmbReligion_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbReligion.Items.Clear();

            DataSet ds = null;
            ds = masBLL.LoadRelegions((int?)null, e.Text);
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];

                int itemOffset = e.NumberOfItems;
                int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
                e.EndOfItems = (endOffset == dt.Rows.Count);
                //int j = 0;
                for (int i = itemOffset; i < endOffset; i++)
                {
                    cmbReligion.Items.Add(new RadComboBoxItem(dt.Rows[i]["RELIGION_NAME"].ToString(), dt.Rows[i]["RELIGION_SEQ"].ToString()));
                }
            }
        }

        protected void cmbBloodGroup_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbBloodGroup.Items.Clear();

            DataSet ds = null;
            ds = masBLL.LoadBloodGroups((int?)null, e.Text);
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];

                int itemOffset = e.NumberOfItems;
                int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
                e.EndOfItems = (endOffset == dt.Rows.Count);
                //int j = 0;
                for (int i = itemOffset; i < endOffset; i++)
                {
                    cmbBloodGroup.Items.Add(new RadComboBoxItem(dt.Rows[i]["BLOOD_GROUP_NAME"].ToString(), dt.Rows[i]["BLOOD_GROUP_SEQ"].ToString()));
                    //j++;
                }
            }
        }
    }
}